
from datetime import datetime
from typing import Union, Any, Optional, List

from pydantic import BaseModel, EmailStr, Field
from sqlalchemy import BigInteger, Boolean, Column, DateTime, ForeignKey, Integer, \
    String, UniqueConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from sqlalchemy.schema import Sequence

from app.common.database import Base
from app.models.base import TableBase, TableBase2


class CardDailyTransData(TableBase2):
    """卡日交易数据表"""
    __tablename__ = "tr_card_daily_trans_data"

    id = Column(Integer, primary_key=True, index=True)
    card_no = Column(String(24), nullable=False, comment='卡号')
    amount = Column(BigInteger, nullable=False, comment='金额')
    trans_date = Column(String(8), nullable=False, comment='交易日期 YYYYMMDD')
    card_type = Column(String(8), comment='卡类型 0.对公帐号 1.银行卡')
    bank_code = Column(String(8), comment='银行编码')
    account_type = Column(String(8), comment='账户类型 1.对私;2.对公')
    currency = Column(String(8), comment='币种')

    __table_args__ = (
        UniqueConstraint('card_no', 'trans_date'),
    )
    

class CardMonthlyTransData(TableBase2):
    """卡月交易数据表"""
    __tablename__ = "tr_card_monthly_trans_data"

    id = Column(Integer, primary_key=True, index=True)
    card_no = Column(String(24), nullable=False, comment='卡号')
    amount = Column(BigInteger, nullable=False, comment='金额')
    trans_month = Column(String(8), nullable=False, comment='交易月份 YYYYMM')
    card_type = Column(String(8), comment='卡类型 0.对公帐号 1.银行卡')
    bank_code = Column(String(8), comment='银行编码')
    account_type = Column(String(8), comment='账户类型 1.对私;2.对公')
    currency = Column(String(8), comment='币种')

    __table_args__ = (
        UniqueConstraint('card_no', 'trans_month'),
    )
    

